package com.itheima.app.controller;

import com.itheima.app.manager.UserLikeManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserLikeController {
    @Autowired
    private UserLikeManager userLikeManager;

    @GetMapping("/tanhua/{likeId}/love")//卡片喜欢
    public void addUserLove(@PathVariable Long likeId){
        userLikeManager.addUserLove(likeId);
    }

    @GetMapping("/tanhua/{likeId}/unlove")//卡片不喜欢
    public void delUserLove(@PathVariable Long likeId){
        userLikeManager.delUserLove(likeId);
    }

    @GetMapping("/users/counts")//相互喜欢、喜欢、粉丝数量统计
    public ResponseEntity myCounts(){
        return userLikeManager.myCounts();
    }

    @GetMapping("/users/friends/{type}")//查询相互喜欢、喜欢、分数用户
    public ResponseEntity myDetail(@PathVariable Integer type,
                                   @RequestParam(value = "page",defaultValue = "1")Integer pageNum,
                                   @RequestParam(value = "pagesize",defaultValue = "10")Integer pageSize){
        return userLikeManager.myDetail(type,pageNum,pageSize);
    }

    @PostMapping("/users/fans/{likeId}")//“我的”中 互相喜欢、喜欢、粉丝里的喜欢功能
    public void fanLove(@PathVariable Long likeId){
        userLikeManager.addUserLove(likeId);
    }

    @DeleteMapping("/users/like/{likeId}")//“我的”中 互相喜欢、喜欢、粉丝里的取消喜欢功能
    public void fanUnlove(@PathVariable Long likeId){
        userLikeManager.delUserLove(likeId);

    }
}
